<?php
class MobileController extends Controller{

	private $_debug=true;

	public function actionIndex(){
		$this->actionIphone();
	}
	
	public function actionIphone(){
		$this->layout='application.views.layouts.iphone';
		$this->render('iphone');
	}

	public function actionRecommend(){
		$this->layout='application.views.layouts.iphone';
				$model=new CoffeeRecommend;
		$model->country='Australia';
		if(isset($_GET['name'])){
			$model->name=$_GET['name'];
		}
		if(isset($_GET['suburb'])){
			$model->suburb=$_GET['suburb'];
		}
		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['CoffeeRecommend']))
		{
			$model->attributes=$_POST['CoffeeRecommend'];
			$model->fromIp=$_SERVER['REMOTE_ADDR'];
			$model->date=time();
			$model->status=CoffeeRecommend::STATUS_PENDING;
			$model->shopId=null;

			if($model->save()){
				Yii::app()->user->setFlash('coffeeRecommend','Thank you. Your recommendation has been processed!');
				$this->redirect(array('recommend'));


			}
		}

		$this->render('/coffeeRecommend/recommend',array(
			'model'=>$model,
		));
	}
	

}